﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace laohan.Common.Common
{
    /// <summary>
    /// 
    /// </summary>
    public static class DateTimeExtension
    {
        /// <summary>
        /// 转换成日期(yyyy-MM-dd)
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static string ToDate(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd");
        }

        /// <summary>
        /// 转换成日期时间（yyyy-MM-dd HH:mm:ss）
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static string ToDateTime(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static string ToDateTimeNoYear(this DateTime dateTime)
        {
            return dateTime.ToString("MM-dd HH:mm:ss");
        }

        /// <summary>
        /// 转换成时间（HH:mm:ss）
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static string ToTime(this DateTime dateTime)
        {
            return dateTime.ToString("HH:mm:ss");
        }
    }
}
